
package com.app.bimo.module_bookrack.mvp.model.model;



import com.app.bimo.commonbusiness.BuildConfig;
import com.app.bimo.commonbusiness.bean.BaseResult;
import com.app.bimo.commonbusiness.network.RetrofitServiceManager;
import com.app.bimo.commonbusiness.util.DataUtil;
import com.app.bimo.library_db.BookData;
import com.app.bimo.module_bookrack.mvp.constract.BookrackReadRecordContract;
import com.app.bimo.module_bookrack.mvp.model.api.service.BookrackService;

import java.util.List;

import io.reactivex.Observable;


public class BookrackReadRecordModel implements BookrackReadRecordContract.Model {
    /**
     * 浏览足迹
     *
     * @return
     */
    @Override
    public Observable<BaseResult<List<BookData>>> getBooks(String page) {
        return RetrofitServiceManager.getInstance().createRetrofit(BuildConfig.APPLICATION_ID, BookrackService.class).getReadRecordBooks(page);
    }

    /**
     * 删除阅读足迹
     *
     * @return
     */
    @Override
    public Observable<BaseResult<Object>> delBooks(String novelid) {
        if (DataUtil.isEmpty(novelid)) {
            return RetrofitServiceManager.getInstance().createRetrofit(BuildConfig.APPLICATION_ID, BookrackService.class).delReadRecordBooks();
        }else {
            return RetrofitServiceManager.getInstance().createRetrofit(BuildConfig.APPLICATION_ID, BookrackService.class).delReadRecordBooks(novelid);
        }
    }

    @Override
    public void onDestroy() {

    }


}
